<%@page import="com.bf.entity.Role"%>
<%@page import="com.bf.entity.Res"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'showAdd.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="admin/resource/css/wzgl.css" />
	<link rel="stylesheet" type="text/css" href="admin/resource/css/layout.css" />
    <link rel="stylesheet" type="text/css" href="admin/resource/css/global.css" />
    <script type="text/javascript">
       function getImpower() {
         <%
           List<Res> allRes = (List<Res>)request.getAttribute("allRes"); 
           Role role = (Role)request.getAttribute("role");
           Set<Res> roleResSet = role.getResourceSet();
           for(Res res : allRes) {
             for(Res roleRes : roleResSet) {
               if(roleRes.getId().equals(res.getId())) {
                  %>
                  document.getElementById("<%=roleRes.getId()%>").checked=true;
                  <%
               }
             }
           }
         %>
       }
    </script>
  </head>
  
  <body class="body" onload="getImpower()">
   <div class="w_100 title_all box"><div class="return"><a href="javascript:history.back(-1)">返回</a></div></div>
	<div class="w_100 right_all center box">
		<div class="quanxian box">
	<h1>对<label>${role.name}</label>授权</h1>
	     <form action="role/role_impower.action" method="post">
	       <input type="hidden" name="id" value="${role.id}">
          <ul class="ul_tree">
           <c:forEach var="menu" items="${allRes}">
             <c:if test="${menu.parent==null}">
            <li class="main_nva"><label>${menu.name}</label>
                <ul>
                  <c:forEach var="menu2" items="${allRes}">
                      <c:if test="${menu2.parent.id==menu.id}">
					<li class="first_nva"><input type="checkbox" name="resourceIds" value="${menu2.id}" id="${menu2.id}"/><label>${menu2.name}</label>
                    	<ul>
                    	  <c:forEach var="menu3" items="${allRes}">
                    	    <c:if test="${menu3.parent.id==menu2.id}">
                    		<li><input type="checkbox" name="resourceIds" value="${menu3.id}" id="${menu3.id}"/>${menu3.name}</li>
                    	   </c:if>
                          </c:forEach>  
                        </ul>
                    </li>
				 </c:if>
				 </c:forEach>
				</ul>
			</li>
			</c:if>
			</c:forEach>
		</ul>
        <h2>
        	<input type="submit" value="授权" />
        </h2>
        </form>
</div>
</body>

<!--JS--->
<script type="text/javascript" src="admin/resource/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="admin/resource/js/menu.js"></script>
</html>
